package com.study.scala.lesson02
import scala.io._
import scala.util.matching.Regex

object filter01 {
  def main(args: Array[String]): Unit = {
    val phone:List[String] = List("15012345678,guangdong,guangzhou",
        "19906409605,shandong,jinan",
        "19901013456,beijing,beijing",
        "18254600815,dongying,dongying"
        )
//  input filter value
    print("请输入过滤值 : " )
    val line = StdIn.readLine()
    val filterString = line
    val Pattern : Regex = filterString.r
    val iterator = phone.iterator
    while (iterator.hasNext){
      val item = iterator.next()
//    use pattern filter
      if(Pattern.findFirstMatchIn(item) != None){
//    output
        println(item)
      }
    }
  }
}